Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get missing metadata contracts task #58

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

moisses89
Copy link
Member

Closes #52

@moisses89 moisses89 requested a review from a team as a code owner January 9, 2025 14:09
@moisses89 moisses89 marked this pull request as draft January 9, 2025 14:09
@moisses89 moisses89 changed the title Periodiq missing contracts Add get missing metadata contracts task Jan 9, 2025
@moisses89 moisses89 marked this pull request as ready for review January 9, 2025 16:32
@coveralls
Copy link

coveralls commented Jan 9, 2025

Pull Request Test Coverage Report for Build 12694200882

Details

  • 17 of 19 (89.47%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 93.258%

Changes Missing Coverage Covered Lines Changed/Added Lines %
app/workers/tasks.py 7 9 77.78%
Totals Coverage Status
Change from base Build 12688135543: -0.1%
Covered Lines: 830
Relevant Lines: 890

💛 - Coveralls

@@ -281,15 +281,20 @@ async def get_abi_by_contract_address(
return None

@classmethod
async def get_contracts_without_abi(cls, session: AsyncSession):
async def get_contracts_without_abi(cls, session: AsyncSession, max_retries: int):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO max_retries parameter should be optional and takes 0 as default value. WDYT?

) -> None:
contract_metadata_service = get_contract_metadata_service()
# Just try the first time, following retries should be scheduled
if await contract_metadata_service.should_attempt_download(
if skip_attemp_download or await contract_metadata_service.should_attempt_download(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpicky: contract_metadata_service.should_attempt_download conditional can be in a separate variable. It would be more understandable in the future. The comment only affects the second part of the condition

@@ -61,3 +66,16 @@ async def get_contract_metadata_task(
)
else:
logging.debug(f"Skipping contract with address {address} and chain {chain_id}")


@dramatiq.actor(periodic=cron("* * * * *")) # Every midnight
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be every midnight not every day.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* * * * * means every minute, right?

@@ -61,3 +66,16 @@ async def get_contract_metadata_task(
)
else:
logging.debug(f"Skipping contract with address {address} and chain {chain_id}")


@dramatiq.actor(periodic=cron("* * * * *")) # Every midnight
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@dramatiq.actor(periodic=cron("* * * * *")) # Every midnight
@dramatiq.actor(periodic=cron("0 0 * * *")) # Every midnight

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add periodic task to retry missing contract metadata
3 participants